<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
<title>aget&lt;kind&gt;</title>
<link rel=stylesheet href="opcode.css">
</head>

<body>

<h1>aget&lt;kind&gt;</h1>

<h2>Purpose</h2>

<p>
Perform the identified array operation at the identified index of the given
array, storing into the value register. 
</p>

<h2>Details</h2>

<table class="instruc">
<thead>
<tr>
  <th>Op &amp; Format</th>
  <th>Mnemonic / Syntax</th>
  <th>Arguments</th>
</tr>
</thead>
<tbody>
<tr>
  <td>44..51 23x</td>
  <td><i>arrayop</i> vAA, vBB, vCC<br/>
    44: aget<br/>
    45: aget-wide<br/>
    46: aget-object<br/>
    47: aget-boolean<br/>
    48: aget-byte<br/>
    49: aget-char<br/>
    4a: aget-short<br/>
  </td>
  <td><code>A:</code> dest value register or pair; (8 bits)<br/>
    <code>B:</code> array register (8 bits)<br/>
    <code>C:</code> index register (8 bits)</td>
</tr>
</tbody>
</table>

<h2>Constraints</h2>

<ul>
  <li>
    A, B and C must be valid register indices in the current stackframe.
  </li>
  <li>
    For the aget-wide variant, also A+1 must be a valid register index in the
    current stackframe.
  </li>
  <li>
    Register vB must contain an array reference. The component type of the
    array must match the variant of the instruction.
  </li>
  <li>
    Register vC must contain an integer value.
  </li> 
</ul>

<h2>Behavior</h2>

<ul>
  <li>
    For all but the -wide variant, the array element at the given index is moved
    into register vA, that is, vA'=array[index].
  </li>
  <li>
    For the -wide variant, the array element at the given index is moved into
    registers vA and v(A+1) as follows:
    <ul>
      <li>
        vA'=array[index] >> 0x20
      </li>
      <li>
        v(A+1)'=array[index] & 0xffffffff;
      </li>
    </ul>
  </li>
  <li>
    If v(A-1) is the lower half of a register pair, v(A-1)' becomes undefined.
  </li>
  <li>
    For all but the -wide variant, if v(A+1) is the upper half of a register
    pair, v(A+1)' becomes undefined.
  </li>
  <li>
    For the -wide variant, if v(A+2) is the upper half of a register pair,
    v(A+2)' becomes undefined.
  </li>
</ul>
    
<h2>Exceptions</h2>

<ul>
  <li>
    NullPointerException if vB=null.
  </li>
  <li>
    ArrayIndexOutOfBoundsException if vC < 0 or vC >= array.length.
  </li>
</ul> 

</body>
</html>
